
import java.util.Scanner;

/**
 * @author Difan Zhao
 */


public class BuildSpring implements Build {
    /**
     * @param line is a scanner that receives user input
     * @param sim is the simulation where object is created
     *        create material object according to user input
     */
    @Override
    public final void build (Scanner line, Simulation sim) {
        int m1 = line.nextInt();
        int m2 = line.nextInt();
        double restLength = line.nextDouble();
        double ks = line.nextDouble();
        if (ks < 0) {
            sim.add(new Bar(sim.getMass(m1), sim.getMass(m2)));
        }
        else {
            sim.add(new Spring(sim.getMass(m1), sim.getMass(m2),
                    restLength, ks));
        }
    }
}
